package pt.isec.a21210392.a21190220.ludotwist.GameLogic;

import pt.isec.a21210392.a21190220.ludotwist.R;

public class EmptyHouse extends House
{
	private static final long serialVersionUID = 1L;
	private int redPinImage;
	private int bluePinImage;
	private int greenPinImage;
	private int yellowPinImage;
	private int redSuperPinImage;
	private int blueSuperPinImage;
	private int greenSuperPinImage;
	private int yellowSuperPinImage;
	
	public EmptyHouse(int number, int line, int column)
	{
		super(number, 
				(number == 1 || (number > 67 && number < 75)) ? R.drawable.just_blue : 
					(number == 18 || (number > 75 && number < 83)) ? R.drawable.just_yellow :
						(number == 35 || (number > 83 && number < 91)) ? R.drawable.just_green :
							(number == 52 || (number > 91 && number < 99)) ? R.drawable.just_red :
								R.drawable.just_white, line, column);
		
		if (number == 1 || (number > 67 && number < 75))
		{
			this.redPinImage = R.drawable.just_blue_red_pin;
			this.bluePinImage = R.drawable.just_blue_blue_pin;
			this.greenPinImage = R.drawable.just_blue_green_pin;
			this.yellowPinImage = R.drawable.just_blue_yellow_pin;
			this.redSuperPinImage = R.drawable.just_blue_red_super_pin;
			this.blueSuperPinImage = R.drawable.just_blue_blue_super_pin;
			this.greenSuperPinImage = R.drawable.just_blue_green_super_pin;
			this.yellowSuperPinImage = R.drawable.just_blue_yellow_super_pin;
		}
		else if (number == 18 || (number > 75 && number < 83))
		{
			this.redPinImage = R.drawable.just_yellow_red_pin;
			this.bluePinImage = R.drawable.just_yellow_blue_pin;
			this.greenPinImage = R.drawable.just_yellow_green_pin;
			this.yellowPinImage = R.drawable.just_yellow_yellow_pin;
			this.redSuperPinImage = R.drawable.just_yellow_red_super_pin;
			this.blueSuperPinImage = R.drawable.just_yellow_blue_super_pin;
			this.greenSuperPinImage = R.drawable.just_yellow_green_super_pin;
			this.yellowSuperPinImage = R.drawable.just_yellow_yellow_super_pin;
		}
		else if (number == 35 || (number > 83 && number < 91))
		{
			this.redPinImage = R.drawable.just_green_red_pin;
			this.bluePinImage = R.drawable.just_green_blue_pin;
			this.greenPinImage = R.drawable.just_green_green_pin;
			this.yellowPinImage = R.drawable.just_green_yellow_pin;
			this.redSuperPinImage = R.drawable.just_green_red_super_pin;
			this.blueSuperPinImage = R.drawable.just_green_blue_super_pin;
			this.greenSuperPinImage = R.drawable.just_green_green_super_pin;
			this.yellowSuperPinImage = R.drawable.just_green_yellow_super_pin;
		}
		else if (number == 52 || (number > 91 && number < 99))
		{
			this.redPinImage = R.drawable.just_red_red_pin;
			this.bluePinImage = R.drawable.just_red_blue_pin;
			this.greenPinImage = R.drawable.just_red_green_pin;
			this.yellowPinImage = R.drawable.just_red_yellow_pin;
			this.redSuperPinImage = R.drawable.just_red_red_super_pin;
			this.blueSuperPinImage = R.drawable.just_red_blue_super_pin;
			this.greenSuperPinImage = R.drawable.just_red_green_super_pin;
			this.yellowSuperPinImage = R.drawable.just_red_yellow_super_pin;
		}
		else
		{
			this.redPinImage = R.drawable.just_white_red_pin;
			this.bluePinImage = R.drawable.just_white_blue_pin;
			this.greenPinImage = R.drawable.just_white_green_pin;
			this.yellowPinImage = R.drawable.just_white_yellow_pin;
			this.redSuperPinImage = R.drawable.just_white_red_super_pin;
			this.blueSuperPinImage = R.drawable.just_white_blue_super_pin;
			this.greenSuperPinImage = R.drawable.just_white_green_super_pin;
			this.yellowSuperPinImage = R.drawable.just_white_yellow_super_pin;
		}		
	}
	
	@Override
	public int getImage() 
	{		
		if (visitor == null)
		{
			return super.getImage();
		}
		if(visitor.getColor().equals("RED"))
		{
			return visitor instanceof SuperPin ? redSuperPinImage : redPinImage;
		}
		if(visitor.getColor().equals("BLUE"))
		{
			return visitor instanceof SuperPin ? blueSuperPinImage : bluePinImage;
		}
		if(visitor.getColor().equals("GREEN"))
		{
			return visitor instanceof SuperPin ? greenSuperPinImage : greenPinImage;
		}
		return visitor instanceof SuperPin ? yellowSuperPinImage : yellowPinImage;
	}
	@Override
	public int getDestiny(Pin pin, int diceResult) 
	{
		return this.getNumber();
	}

	@Override
	public void arrivedHere(Pin pin, int diceResult)
	{
		this.setVisitor(pin);
	}
}